package com.tongcao.cn.excel;

import java.io.Serializable;
import java.util.Map;

/**
 * @author:tongcao
 * @since:2019/11/25 11:04
 * Description:
 */
public abstract class AbstractExcelProcessor {


    /**
     * @Fields EXCEL_START_ROW: excel模板中，第一行是头，第二行是标题，第三行开始是数据
     */
    public static final int EXCEL_START_ROW = 3;
    /**
     * @Fields EXCEL_TOTAL_COL: 共21列数据
     */
    public static final int EXCEL_TOTAL_COL = 22;


    protected String fileSuffix = "";

    /**
     * @param task
     * @param taskCallback
     */
    public void process(Task task, TaskCallback taskCallback) {
        taskCallback.setSuccess(false);
        Map<String, Serializable> param = task.getParam();

        //step 2 获取excel文件
        byte[] resultExcelBytes = null;

        try {
            resultExcelBytes = getExcelBytes();
            if (resultExcelBytes == null || resultExcelBytes.length == 0) {
                String errMsg = "大文件导出任务获取excel文件为空";
                taskCallback.setMsg(errMsg);
                return;
            }
        } catch (Exception e) {
            String errMsg = "大文件导出任务获取excel文件异常" + e;
            taskCallback.setMsg(errMsg);
            return;
        }


    }

    protected abstract byte[] getExcelBytes();

}